Skip to content

feat: Add FDv2 wire format and protocol handler#177

Open
beekld wants to merge 3 commits into
mainfrom
bklimt/SDK-2588/fdv2-wire-types
Open

feat: Add FDv2 wire format and protocol handler#177
beekld wants to merge 3 commits into
mainfrom
bklimt/SDK-2588/fdv2-wire-types

Conversation

@beekld

@beekld beekld commented Jun 23, 2026

Copy link
Copy Markdown

Summary

  • Introduces the fdv2 module:
    • wire-format types
    • assembled ChangeSet / Selector types
    • protocol-handler state machine that folds SSE events into change sets
  • Object bodies stay as raw serde_json::Value; typed deserialization will live in a later translator.
  • Matches the C++ SDK on permissive-parsing choices:
    • Selector keeps the deprecated version field alongside state
    • Goodbye and FDv2Error use optional fields to tolerate permissively-parsed wire data
  • Module is annotated #[allow(dead_code)] for now: types are covered by unit tests but not yet reachable from the production data path.

Note

Low Risk
New code is test-only and not on the live flag data path; behavior changes only when FDv2 is integrated later.

Overview
Adds a new fdv2 module (registered in lib.rs but #[allow(dead_code)] until the streaming data path uses it) for LaunchDarkly FDv2 streaming.

Wire layer (wire.rs): deserializes SSE payloads—server-intent, put-object / delete-object, payload-transferred, error, goodbye—with permissive parsing (unknown intent codes → Unknown, optional fields on Goodbye / FDv2Error). Put bodies stay as serde_json::Value for a later translator.

Protocol (protocol.rs): FDv2ProtocolHandler folds events into ChangeSet values (None / Full / Partial plus put/delete ops and a selector from payload-transferred.state). It tracks full vs partial transfer intent, allows further put/delete cycles without a new server-intent after the first payload, clears buffered changes on server error while keeping transfer state, and resets on goodbye.

Unit tests cover wire parsing and protocol edge cases (malformed JSON, unknown events, protocol violations).

Reviewed by Cursor Bugbot for commit 7c71c55. Bugbot is set up for automated code reviews on this repo. Configure here.

@beekld
beekld marked this pull request as ready for review June 25, 2026 17:59
@beekld
beekld requested a review from a team as a code owner June 25, 2026 17:59
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs
pub(super) version: u64,
pub(super) kind: String,
pub(super) key: String,
pub(super) object: serde_json::Value,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we think about using serde's raw value? Might save some cycles if we find we need to discard part of the stream.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer keeping this as Value to be consistent with how it's written in C++ and Java. I'm open to discussing it further.

Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b84b315. Configure here.

Comment thread launchdarkly-server-sdk/src/fdv2/protocol.rs
Comment thread launchdarkly-server-sdk/src/fdv2/protocol.rs
@beekld
beekld requested a review from keelerm84 July 14, 2026 20:19
@beekld

beekld commented Jul 17, 2026

Copy link
Copy Markdown
Author

I decided to move some of the types to a separate module, to better reflect how the other SDKs are structured.

@beekld
beekld force-pushed the bklimt/SDK-2588/fdv2-wire-types branch from a81f3b6 to 7c71c55 Compare July 17, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants